package com.yycx.module.bus.provider.handler.haiying.tasktodo.settle.invoice;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.mybatis.interceptor.DeleteInterceptor;
import com.yycx.common.mybatis.query.CriteriaDelete;
import com.yycx.module.bus.provider.service.hy.BusHyorderInoviceDetailsService;
import com.yycx.module.bus.provider.service.BusPaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.Serializable;

/**
 * 开票单删除
 *
 * @author zyf
 */
@Component
public class HyInvoicePaymentDeleteHandler implements DeleteInterceptor {

    @Resource
    private BusPaymentService paymentService;
    @Autowired
    private BusHyorderInoviceDetailsService orderInoviceDetailsService;

    @Override
    public void prepare(CriteriaDelete criteriaDelete, EntityMap entityMap) {

    }

    @Override
    public void complete(CriteriaDelete cd, EntityMap params) {
        Serializable paymentId = cd.getIdValue();
        Integer settleType = cd.getRequestMap().getInt("settleType");
        //清空关联ID
        orderInoviceDetailsService.clearPayId(paymentId, settleType);
        //删除市场资金支付单
        paymentService.deleteByParentId(paymentId);
    }
}
